//
//  ZFLTabbarBackgroundView.m
//  iOSAppDevRepo_Example
//
//  Created by 翁胜琼 on 2019/2/13.
//  Copyright © 2019 折疯了. All rights reserved.
//

#import "ZFLTabbarBackgroundView.h"

@implementation ZFLTabbarBackgroundView


- (void)drawRect:(CGRect)rect {
    // Drawing code
    
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineJoin(context, kCGLineJoinRound);
    CGContextSetFillColor(context, CGColorGetComponents([UIColor greenColor].CGColor));
    
//    CGPoint centerPoint = CGPointMake(rect.size.width / 2, rect.size.height / 2);
//
//    CGFloat width = rect.size.width;
//    CGFloat height = rect.size.height;
//    CGFloat radius = (width > height ? width : height)/2;
//    CGFloat startAngle = 0 * M_PI * 2 - M_PI_2;
//    CGFloat endAngle = 0.5 * M_PI * 2 - M_PI_2;
//    BOOL clockwise = true;
//
//    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:clockwise];
//    [path addLineToPoint:centerPoint];
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointZero];
    [path addLineToPoint:CGPointMake(Screen_Width * 0.3, 0)];
    
    CGPoint curvePoint1 = CGPointMake(Screen_Width * 0.3, 0);
    CGPoint curvePoint2 = CGPointMake(Screen_Width * 0.5, 20);
    CGPoint curvePoint3 = CGPointMake(Screen_Width * 0.7, 0);
    
    // 绘制曲线
    [path addCurveToPoint:curvePoint1 controlPoint1:curvePoint2 controlPoint2:curvePoint3];
//    [path addArcWithCenter:curvePoint2 radius:10 startAngle:- M_PI_2 endAngle:M_PI clockwise:true];
    [path addLineToPoint:CGPointMake(Screen_Width, 0)];
    [path addLineToPoint:CGPointMake(Screen_Width, rect.size.height)];
    [path addLineToPoint:CGPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect))];
    [path addLineToPoint:CGPointMake(0, 0)];
    
    [path fill];
    
    CGContextAddPath(context, path.CGPath);
    
}

@end
